﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace Statistic
{
    public class Protocol
    {
        private string result_;

        /**
         * Gets a page and returns the html code
         * @param htmlCode
         *   html page
         * @return result_
         *   the html code
         */
        public string GetHtmlCode(string htmlCode)
        {
            Uri a = new Uri(htmlCode);
            try
            {
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(a);
                myRequest.Method = "GET";
                myRequest.UserAgent = "Mozilla/5.0";
                WebResponse myResponse = myRequest.GetResponse();
                StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
                result_ = sr.ReadToEnd();
                sr.Close();
                myResponse.Close();
            }
            catch (Exception)
            {
                //Console.WriteLine("error");
            }
            return result_;
        }
    }
}
